package com.zqq.baselibrary.ui.activity

import android.os.Bundle
import android.support.v4.view.ViewPager
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.view.Window
import android.widget.FrameLayout
import com.trello.rxlifecycle.components.support.RxAppCompatActivity
import com.zqq.baselibrary.common.AppManager
import org.jetbrains.anko.find

/**
 * 基类
 * wc
 * @author zqq on 2018/7/26
 */
open class BaseActivity : RxAppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        AppManager.instance.addActivity(this)
    }


    override fun onDestroy() {
        super.onDestroy()
        AppManager.instance.finishActivity(this)
    }

    //获取Window中视图content
    val contentView: View
        get() {
            //因为所有布局都是放在framelayout里的
            //Window下DecorView的布局是LinearLayout（包含title和content：且是FrameLayout）
            val content: FrameLayout = find<FrameLayout>(android.R.id.content)
            return content.getChildAt(0)
        }


}